<template>
	<!-- 包含山东省展示专业+院校 -->
	<view>
		<view class="flex-row center-row container-bg">
			<view class="flex-column  " style="width: 84rpx; height: 100%;  ">


				<text v-if="majordata.isNewly.length>0"
					style="font-size: 38rpx;white-space: nowrap;margin-top: 5rpx;position: absolute;top: 15rpx;left: 35rpx;font-weight: 400">新增</text>
				<icon-index v-else :number="Number(data.chance_lv)" :index="String(majordata.chance) " baifenhao="%"
					fontsSize='28rpx'></icon-index>

				<text
					style="position: absolute;top: 70rpx; left: 40rpx; width: 56rpx; height: 60rpx;text-align: center; font-weight: bold;"
					:style="{'color':chanceColor}">{{chanceLab}}</text>
				<text v-if="majordata.isNewly.length==0"
					style="position: absolute;top: 120rpx; left: 30rpx; height: 60rpx; font-size: 20rpx;color: #999;">{{majordata.probabilityExplain}}</text>
				<text style="width: 84rpx;"></text>
			</view>
			<!-- 学校类别 如 985 211 -->
			<view class="flex-column container-right" style="width: 460rpx;">
				<!-- 专业 -->
				<view class="flex-row schoolmajor-major flex-column" style="flex-direction: column;"
					@tap.stop="onToProfessPage(majordata)">
					<view style="margin-bottom: 10rpx;font-size: 36rpx;" :class="majordata.isFit==0?'changeColor':''">
						{{majordata.professionRealName}}
					</view>
					<view class="one-school-city" :class="majordata.isFit==0?'changeColor':''" style="color: #333;">
						{{majordata.remarkExt}}
					</view>

					<text v-if="data.percent_pc" class="one-school-city text-pc" style="color: #333;">专业测评
						{{data.percent_pc}} %</text>
				</view>
				<!-- 代码 -->
				<view class="flex-column">
					<view class="plan">
						<text>
							{{data.planYear + '年计划:'}}
							<text class="text-464646" :class="data.isFit==0?'changeColor':''">
								{{ data.planNum + '人' }}
							</text>
						</text>
						<text>
							<text class="text-464646">
								{{ data.chooseSubjectText }}
							</text>
						</text>
					</view>

					<view class="money">
						<text>
							学制:
							<text class="text-464646">
								{{ data.learnYear }}年
							</text>
						</text>
						<text>
							学费:
							<text class="text-464646">
								￥{{ data.cost }}
							</text>
						</text>
						<text>
							代码:
							<text class="text-464646">
								{{ data.professionEnrollCode }}
							</text>
						</text>
					</view>

				</view>
				<!-- 历年数据，新增专业不展示 -->
				<view :class="majordata.isFit==0?'changeColor':''"
					v-if="majordata.moreYear.length>0&&majordata.isNewly.length<=0" class="fromBox"
					style="white-space: wrap;">
					<view class="flex-row fromBox-head">
						<view style="width: 15%; text-align: center;" align="center">年份</view>
						<view style="width: 15%; text-align: center;" align="center">科类</view>
						<view style="width: 15%; text-align: center;" align="center">录取</view>
						<view style="width: 20%; text-align: center;" align="center">最低分</view>
						<view style="width: 24%; text-align: center;" align="center">最低位次</view>
						<view style="width: 28%; text-align: center;" align="center">
							<view class="th-item flex-row center-column align-center" @tap.stop="popupMessage">
								<view>等效位差</view>
								<image src="https://mcdn.chatgk.com/xcx/static/images/zhinengtianbao/wenhao.png" mode=""
									style="width: 18rpx; height: 18rpx;"></image>
							</view>
						</view>
					</view>
					<view class="flex-row flex-row-table" v-for="(ele, index) in data.moreYear" :key="index">
						<view style="width: 15%; text-align: center;" align="center">
							{{ ele.year }}
						</view>
						<view style="width: 15%; text-align: center;" align="center">
							{{ele.course}}
						</view>
						<view style="width: 15%; text-align: center;" align="center">
							{{ ele.enterNum || ' - ' }}
						</view>
						<view style="width: 20%; text-align: center;" align="center">
							{{ ele.minScore || ' - ' }}
							<text v-if="ele.zjText&&ele.zjText.length>0&&ele.minScore*1>0"
								@tap="onzhengshowboxopen(ele.year)" class="" style="color: red;">
								征
							</text>
							<text v-else style="color: transparent;">
								征
							</text>
						</view>
						<view style="width: 22%; text-align: center;" align="center">
							{{ ele.minRank || ' - ' }}
						</view>
						<view style="width: 26%; text-align: center;" align="center">
							<span v-if="ele.equivalentBitDifference == '-' || !ele.equivalentBitDifference"> - </span>
							<span v-else-if="ele.equivalentBitDifference < 0" style="color: #FF7E36;;">
								低{{ ele.equivalentBitDifference.toString().substring(1) }}</span>
							<span v-else-if="ele.equivalentBitDifference >= 0" style="color: #20ED33;">
								高{{ ele.equivalentBitDifference }}</span>
						</view>

					</view>
				</view>

				<!-- 学校名 -->
				<view class="flex-row text-right-bold" style="margin-top: 20rpx;">
					<view class="flex-column">
						<text @tap.stop="triggerGetMoreYearInfo" style="margin-bottom: 10rpx;font-size: 28rpx;"
							:class="data.isFit==0?'changeColor':''">{{data.collegeRealName}}</text>
						<text class="text-999 collegeRemark" :class="data.isFit==0?'changeColor':''"
							style="color: #333;">{{data.collegeRemark}}</text>
					</view>
				</view>
				<!-- 列表排名区域 -->
				<view class="flex-column text-999" style="">
					<text class="text-999 label">{{data.features.join(' / ') }} </text>
					<view class="province-city">
						<view class="province">
							<image class="address"
								src="https://mcdn.chatgk.com/xcx/static/images/zhinengtianbao/address.png" mode="">
							</image>
							{{ data.provinceName + ' ' + data.cityName + ' ' + data.categories.join(' / ') + ' / ' + data.natureType + ' / '+ '排名'+(data.rank <= 0 ? '-':data.rank) }}
						</view>
					</view>
				</view>

				<view class="flex-column">
					<view class="plan">
						<text>
							{{data.planYear + '年计划:'}}
							<text class="text-464646" :class="data.isFit==0?'changeColor':''">
								{{ data.planNum + '人' }}
							</text>
						</text>
						<text>
							代码:
							<text class="text-464646">
								{{ data.collegeEnrollCode }}
							</text>
						</text>
					</view>
				</view>


			</view>

			<button v-show="data.isFit==1" class="button-major" :class="oneBtnColor ? 'select':''"
				@tap.stop="listOneAddVolunteers">{{oneBtnColor?'已填'+SelectOneText:'填报'}}</button>
			<view v-show="data.isFit==0" class="button-major2" :class="data.isFit==0?'changeColor':''">
				选科不符
			</view>

		</view>
	</view>
	<zheng-show v-if="zhengshowbox" :yearText="yearText" @onzhengshowbox="onzhengshowbox"
		style="width: 100vw;height: 100vh;position: fixed;top: 0;z-index: 99999;"></zheng-show>

	<view class="popup-center" v-show="opens" @touchmove.stop.prevent="stopscroll">
		<view class="popup-center-box">
			<view class="p-c-b-top">
				<view class="top-title">
					什么是等效位差？
				</view>
				<text>
					历年等效位差根据考生历年的等效位-历年位次的差值得出，
					换算后的等效位差可更精准的与历年位次进行比较。
				</text>
			</view>
			<view class="p-c-b-bottom">
				<view class="bottom-line">
				</view>
				<image style="width: 60rpx;height: 40%;"
					src="https://mcdn.chatgk.com/xcx/static/images/midTabBar/chacha@3x.png" mode="" @tap.stop="endPopup">
				</image>
			</view>
		</view>
	</view>
</template>

<script>
	import userManager from '@/common/manager/user-manager.js'
	export default {
		name: "zhineng-xuanxiao-list-one",
		props: {
			data: {
				type: Object,
			},
			majordata: {
				type: Object,
			},
			oneBtnColor: {
				type: Boolean,
				default: false
			},
			index: {
				type: Number,
				default: 0
			},
			// volunteerNumber: {
			// 	type: Number,
			// 	default: 0
			// },
			// zhiyuanbiaoData: {
			// 	type: Number,
			// 	default: 0
			// }
		},
		emits: ['getMoreYearInfo', 'listOneAddVolunteer'],
		data() {
			return {
				state: false, //重庆部分地区TAB1专用状态
				canvasNumber: 0,
				chanceLab: "--",
				chanceTit: "--",
				yearText: '',
				zhengshowbox: false,
				opens: false,
			};
		},
		created() {

			this.canvasNumber = Math.floor(Math.random() * 100) + 1
		},
		mounted() {},
		watch: {
			data: {
				handler(newVal) {
					this.state = this.oneBtnColor
					const lv = this.data.chance_lv
					if (lv == 1) {
						this.chanceLab = '冲'
						this.chanceTit = '风险极大'
						this.chanceColor = '#FF3B0A'
					} else if (lv == 2) {
						this.chanceLab = '稳'
						this.chanceTit = '风险中等'
						this.chanceColor = '#FFD43A'
					} else if (lv == 3) {
						this.chanceLab = '保'
						this.chanceTit = '风险极小'
						this.chanceColor = '#27EC61'
					}
				},
				immediate: true,
				deep: true
			},
			volunteerInfo: {
				handler(newVal) {},
				deep: true
			}
		},
		computed: {
			SelectOneText() {
				let text = 0
				let info = this.$store.state.user.volunteerInfo
				info.forEach((item, index) => {
					// if (item.id == this.data.id) {
					let code1 = item.majorsInfo[0].collegeCode + item.majorsInfo[0].majorCode + item.majorsInfo[0]
						.professionEnrollCode
					let code2 = this.data.majorsInfo[0].collegeCode + this.data.majorsInfo[0].majorCode + this.data
						.majorsInfo[0].professionEnrollCode

					if (code1 == code2) {
						text = index + 1
					}
				})
				return text
			},
		},
		methods: {
			popupMessage() {
				this.opens = true
			},
			endPopup() {
				this.opens = false
			},
			stopscroll() {
				console.log("禁止滚动");
			},
			onzhengshowboxopen(year) {
				this.yearText = year
				this.zhengshowbox = true
			},
			onzhengshowbox() {
				this.zhengshowbox = false
			},
			//重庆类别1选择函数
			// SelectOneText() {
			// 	let text = 0
			// 	let info = userManager.getVolunteerInfo()

			// 	info.forEach((item, index) => {
			// 		if (item.majorsInfo[0].collegeCode + item.majorsInfo[0].majorCode == this.data.majorsInfo[0]
			// 			.collegeCode + this.data.majorsInfo[0].majorCode) {

			// 			text = index + 1
			// 		}
			// 	})
			// 	return text
			// },

			listOneAddVolunteers() {
				// if (this.zhiyuanbiaoData >= 3) {

				// } else {
				const newdata = JSON.parse(JSON.stringify(this.data))
				newdata.majorsInfo = []
				newdata.majorsInfo.push(this.majordata)
				// this.$emits()
				this.$emit("listOneAddVolunteer", newdata)
				// }


			},
			//点击拉起学校弹框
			triggerGetMoreYearInfo() {
				let newdata = {
					province: this.data.provinceCode,
					code: this.data.collegeCode
				}
				this.$request.searchSchool(newdata).then(res => {
					uni.navigateTo({
						url: '/subpackages/subpackage1/pages/searchcollege/collegeDetails/college-details?data=' +
							JSON.stringify(
								res.data[0])
					})
				}).catch(res => {})
				// this.$emit('getMoreYearInfo', this.data)
			},
			/**
			 * @description 跳转前往专业详情页面
			 * @param {Object} data 需要跳转的专业数据
			 */
			onToProfessPage(data) {
				// 通过majorCode的长度来判断专业层次 2~4为level.2， 4以上就为level.3
				let level = data.majorCode.length > 4 ? 3 : 2
				// 列表 /subpackages/subpackage1/pages/searchmajor/search-major-list?majorsArr=
				if (level == 2) {
					// this.$request.searchAllMajored({
					// 	code: data.majorCode,
					// 	level
					// }).then(res => {
					// 	uni.navigateTo({
					// 		url: "/subpackages/subpackage1/pages/searchmajor/search-major-list?majorsArr=" + encodeURIComponent(
					// 			JSON.stringify(res.data[0]))
					// 	})

					// })
					uni.navigateTo({
						url: '/subpackages/subpackage1/pages/searchmajor/see-major-class?code=' + data.majorCode
					})
				} else {
					uni.navigateTo({
						url: "/subpackages/subpackage1/pages/searchmajor/search-major-majordetail?code=" +
							data.majorCode,
					})
				}
			}
		}

	}
</script>

<style lang="scss" scoped>
	.flex-row {
		display: flex;
		flex-direction: row;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
	}

	.align-center {
		align-items: center;
	}

	.space-between {
		display: flex;
		justify-content: space-between;
	}

	.difference {
		display: flex;
		flex-direction: row;
	}

	.popup-center {
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.6);
		position: fixed;
		top: 0;
		z-index: 999;
		// display: flex;
		// justify-content: center;
		// align-items: center;
		// overflow: hidden;

		.popup-center-box {
			width: 80%;
			height: 500rpx;
			position: absolute;
			top: 35%;
			left: 10%;

			.p-c-b-top {
				width: 100%;
				height: 50%;
				background-color: #fff;
				padding: 40rpx;
				font-size: 26rpx;
				line-height: 40rpx;
				box-sizing: border-box;
				border-radius: 20rpx;

				.top-title {
					width: 100%;
					display: flex;
					justify-content: center;
					font-size: 38rpx;
					font-weight: 500;
					margin-bottom: 20rpx;
				}
			}

			.p-c-b-bottom {
				width: 100%;
				height: 30%;
				display: flex;
				flex-direction: column;
				align-items: center;

				.bottom-line {
					width: 2rpx;
					height: 40%;

					background-color: #fff;
				}
			}
		}
	}

	.flex-row {
		display: flex;
		flex-direction: row;
	}

	button::after {
		border: none;
	}

	.container-bg {
		background: #FFFFFF;
		margin: 24rpx 32rpx 10rpx 32rpx;
		padding: 24rpx 0 26rpx 20rpx;
		border-radius: 20rpx;
		width: calc(100% - 88rpx);
		position: relative;
	}

	.container-right {
		/* width: 100%; */
		margin: 0 100rpx 0 20rpx;
	}

	.text-left {
		color: #FF3B0A;
		font-size: 28rpx;
		font-weight: bold;
	}

	.schoolmajor-major {
		width: 85%;
		color: #464646;
		font-size: 28rpx;
		font-weight: bold;
	}

	.label {
		width: 90%;
		font-size: 20rpx !important;
	}

	.province-city {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		font-size: 20rpx;
		width: 90%;
		color: #999999;

		.province {
			// line-height: 34rpx;
			margin: 0 6rpx 0 0;
			display: flex;
			flex-direction: row;
			align-items: center;

			.address {
				width: 14rpx;
				height: 20rpx;
				margin-right: 8rpx;
			}
		}
	}

	.plan,
	.money {
		display: flex;
		justify-content: start;
		align-items: center;
		font-size: 22rpx;
		// line-height: 32rpx;
		color: #999999;
		margin: 8rpx 0 0 0;

		text {
			display: inline-block;
		}

		.text-464646 {
			color: #464646;
			font-weight: bold;
			margin-right: 10rpx;
			font-size: 24rpx;
		}
	}

	.text-right-bold {
		color: #464646;
		font-size: 26rpx;
		font-weight: bold;
		width: 80%;

		.flex-column {
			display: flex;
			flex-direction: column;

			.collegeRemark {
				// width: 80%;
				color: #333333;
				font-size: 24rpx;
				font-weight: normal;
				line-height: 34rpx;
			}
		}
	}

	.text-999 {
		color: #999;
		font-size: 24rpx;
		margin-bottom: 10rpx;
	}

	.text-464646 {
		color: #464646;
		font-size: 24rpx;
		margin-bottom: 10rpx;
	}

	.text-22 {
		color: #999;
		font-size: 22rpx;
	}

	.button-major {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		height: 48rpx;
		line-height: 48rpx;
		color: #FF3B0A;
		border: 2rpx solid #FF3B0A;
		border-radius: 24rpx;
		font-size: 22rpx;
		background-color: transparent;
		margin-bottom: 10rpx;
	}

	.button-major2 {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		height: 48rpx;
		line-height: 48rpx;
		color: #FF3B0A;
		font-size: 22rpx;
		background-color: transparent;
		margin-bottom: 10rpx;

	}

	.button-major.select {
		line-height: 50rpx;
		color: #FF3B0A;
		background: rgba(255, 59, 10, 0.2);
		border: none;
	}

	.margin-bottom {
		margin-bottom: 20rpx;
	}

	.fromBox {
		width: 100%;
		font-size: 12rpx;
		margin-top: 10rpx;
		margin-left: -10rpx;
		padding-bottom: 24rpx;
		border-bottom: 1rpx solid #CCCCCC;

		.fromBox-head {
			font-size: 22rpx;
			color: #999999;
		}

		.flex-row-table {
			color: #666666;
			font-size: 20rpx;
			margin-top: 10rpx;
		}

		.center-row {
			align-items: center;
		}
	}

	.one-school-city {
		width: 85%;
		font-weight: 400;
		font-size: 24rpx;
		margin-bottom: 10rpx;
	}

	.canvas-box {
		position: absolute;
		top: 24rpx;

	}

	.changeColor {
		color: #999999 !important;
	}
</style>